package com.zhuiyi.yiqingbackend.service.impl;

import com.zhuiyi.yiqingbackend.domain.Banner;
import com.zhuiyi.yiqingbackend.mapper.BannerMapper;
import com.zhuiyi.yiqingbackend.service.BannerService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class BannerServiceImpl implements BannerService {

    @Resource
    private BannerMapper bannerMapper;

    @Override
    public List<String> getBanners() {
//        遍历banner表，获取url
        List<Banner> banners = bannerMapper.getBanners();
        List<String> bannerUrls = banners.stream().map(Banner::getUrl).collect(java.util.stream.Collectors.toList());
        return bannerUrls;
    }

    @Override
    public boolean addBanner(Banner banner) {
            return bannerMapper.addBanner(banner);
    }

    @Override
    public boolean delereBannerById(int id) {
        return bannerMapper.delereBannerById(id);
    }

    @Override
    public boolean updateBanner(Banner banner) {
        return  bannerMapper.updateBanner(banner);
    }

    @Override
    public Banner getBannerById(int id) {
        return  bannerMapper.getBannerById(id);
    }
}
